package com.ch.boundarycallbackdemo.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import com.ch.boundarycallbackdemo.R
import com.ch.boundarycallbackdemo.bean.Data

class NewsAdapter(config: DiffUtil.ItemCallback<Data>) :
    PagedListAdapter<Data, NewsViewHolder>(config) {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewsViewHolder {
        val rootView = LayoutInflater.from(
            parent
                .context
        ).inflate(R.layout.item_layout, parent, false)
        return NewsViewHolder(rootView)
    }

    override fun onBindViewHolder(holder: NewsViewHolder, position: Int) {
        val data = getItem(position)
        holder.mTextView.text = data?.title
    }
}